#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
    int a1, a2;
    long long s1;
    while (1) {
        a1 = 0;
        a2 = 0;
        s1 = 0;
        cout << "请输入待转换的数字的进制" << endl;
        cin >> a1;
        cout << "请输入待转换的数字" << endl;
        if (a1 == 16) {
            scanf("%x", &s1);
        } else if (a1 == 10) {
            scanf("%d", &s1);
        }

        cout << "请输入要转换的进制" << endl;
        cin >> a2;

        cout << "转换结果：" << endl;
        if(a2==10){
            printf("%d",s1);
            cout<<endl;
            cout<<endl;
        } else if(a2==16){
            printf("%x \n",s1);
            cout<<endl;
            cout<<endl;
        }


    }

    return 0;
}